<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>车辆进入登记</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/xadmin.css">
    <script type="text/javascript" src="../../js/jquery-3.2.1.js"></script>
    <script type="text/javascript" src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
  </head>
  
  <body>
	<div class="x-body">
		<form class="layui-form" lay-filter="CarIN">
			<h2 align="center">车辆进入登记</h2></br>
			<div class="layui-input-block" id = "view">
				<label for="CarLicense" class="layui-form-label"> <span
					class="x-red">*</span>车牌号码:
				</label>
				
				<div class="layui-input-inline " id = "view" style="width:150px;">
					<select id="CarINselectProvince" name="CarINselectProvince">
						<option value="0">请选择省字</option>
	
	  				</select>
				</div>
				
				<div class="layui-input-inline" id = "view" style="width:150px;">
					<select id="CarINselectFirstElem" name="CarINselectFirstElem">
						<option value="0">请选择城市字母</option>
	
	  				</select>
				</div>
				<div class="layui-input-inline" id = "view" style="width:150px;">
					<input type="text" id="CarINotherElems" name="CarINotherElems"
						required="" lay-verify="required" autocomplete="off"
						class="layui-input" placeholder="车牌剩余部分" >
				</div>
				
				
			</div>
			
			<div class="layui-input-block" id = "view">
				<label for="zone" class="layui-form-label"> <span
					class="x-red">*</span>进入分区
					</label>
				<div class="layui-input-inline" id = "view" style="width:100px;">
					
					
					<div class="layui-input-inline " id = "view" style="width:200px;">
						<select id="selectZone" name="selectZone">
							<option value="0">请选择停车场分区</option>
	
		  				</select>
					</div>
				</div>
		</div>
		<div class="layui-input-block" id = "view">
			<div class="layui-form-item">
				<label for="L_repass" class="layui-form-label"> </label>
				<button class="layui-btn" lay-filter="add" lay-submit="">
					增加</button>
			</div>
		</div>
		</form>
	</div>
	<script>
	layui.use(['form','layer'], function(){
        var form = layui.form
        ,layer = layui.layer;
      
        
        //初始化
        $(function(){
        	
        	//初始化车牌选择
        	var provinces = new Array("京","沪","浙","苏","粤","鲁","晋","冀",
                    "豫","川","渝","辽","吉","黑","皖","鄂",
                    "津","贵","云","桂","琼","青","新","藏",
                    "蒙","宁","甘","陕","闽","赣","湘");
        	
        	for(var i = 0;i<provinces.length;i++){
        		$("#CarINselectProvince").append("<option value="+provinces[i]+">"+provinces[i]+"</option>");
      		    form.render();
        	}
        	
        	
        	var Elem = new Array("A","B","C","D","E","F","G","H",
                    "I","J","K","L","M","N","O","P",
                    "Q","R","S","T","U","V","W","X",
                    "Y","Z");
        	
        	for(var i = 0;i<Elem.length;i++){
        		$("#CarINselectFirstElem").append("<option value="+Elem[i]+">"+Elem[i]+"</option>");
      		    form.render();
        	}
        	
        	
        	
        	
        	//发异步请求查询分区停车场信息
        	//初始化下拉菜单
            $.ajax({
            	type: "post",
              	url: "",
              	async: true,
              	success:function(result){
              		/* $.each(result.listvillage,function(index,value){
                		    $("#selectvillage").append("<option value="+value.villageId+">"+value.villageName+"</option>");
                		    form.render();
                		}); */
              	},
              	error:function(){
              		layer.msg("分区停车场的信息没有正确地加载到选择菜单中!",{icon:2,time:1500});
              	}
            });
        });
        
        

        //监听提交车辆登记进入
        form.on('submit(add)', function(data){
        	
        	
            var Carlicense = $("#CarINselectProvince").val()+$("#CarINselectFirstElem").val()+$("#CarINotherElems").val();
        	
            console.log(Carlicense);
            

        	if(check_license(Carlicense)){
        		
        		//发异步请求登记车辆进入
        		
        		
        	}else{
        		layer.msg("车牌号码不合法!",{icon:2,time:1500});
        	}

        	
            return false;
        });
        
        
        function check_license(licensePlate) {
        	var re = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/;
        	if(licensePlate.search(re) == -1) {
        		return false;
        	} else {
        		return true;
        	}
        }
        
    });
	</script>

  </body>

</html>